package com.cloud.school.app.config.security;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import okhttp3.MediaType;

/**
 * @ClassName DefaultSendSms
 * @Description TODO
 * @Author 36297
 * @Date 2019/2/1 10:01
 * @Version 1.0
 */
@Slf4j
public class DefaultSendSms {
    private static final String account = "N7101502";
    private static final String password = "tAh557cQP";
    private static final String url = "http://smssh1.253.com/msg/send/json";

    public static void sendSms(String telephone, String validateCode) {
        MessageBody messageBody = new MessageBody();
        messageBody.setPhone(telephone);
        messageBody.setMsg("【并集】您正在申请手机注册，验证码为：" + validateCode + "，5分钟内有效！");
        OkHttpUtil.sendPostAync(url, JSON.toJSONString(messageBody), MediaType.parse("application/json"), m -> log.info(m));
    }


    public static class MessageBody {
        private String account = DefaultSendSms.account;
        private String password = DefaultSendSms.password;
        private String msg;
        private String phone;

        public String getAccount() {
            return account;
        }

        public String getPassword() {
            return password;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        public String getPhone() {
            return phone;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }
    }
}

